var str1 = [1,2,3];
var str2 = [4,5,6,7];

function fn(arr1,arr2) {
  var result = [];
  var arr1_len = arr1.length;
  var arr2_len = arr2.length;
  for(i = 0;i<arr1_len+arr2_len;i++){
    //三种情况，数组一长度比二大
    if (arr1_len > arr2_len){
      if (i % 2 === 0 || i > 2*arr2_len){
        result.push(arr1.shift());
      }else {
        result.push(arr2.shift());
        // console.log(i);
      }
    }
    // 三种情况，数组一长度等于或比二小
    else if (arr1_len <= arr2_len){
      if ((i % 2 ===1) || i >= 2*arr1_len){
        result.push(arr2.shift());
      }else {
        result.push(arr1.shift());
      }
    }
  }
  return result;
}
// fn(str1,str2);
console.log(fn(str1,str2));
